import config from "@/config/config.json";
// export const goWebview = ({
//   domain = config.siteDomain,
//   pageUrl,
//   redirect,
//   token
// }) => {
//   let goUrl = `${domain}/#/${pageUrl}`;
//   if (redirect) {
//     goUrl = `${goUrl}?mp_redirect=${redirect}`;
//   }
//   let encodedUrl = encodeURIComponent(goUrl);
//   console.log(decodeURIComponent(encodedUrl), 'nnnnnnnnnnnnnnnnnnnn');
//   wx.navigateTo({
//     url: `/pages/webview/index?url=${encodedUrl}`,
//   });
// };

const getGoUrl = ({
  domain,
  pageUrl,
  redirect,
  token,
  inviteCode
}) => {
  return `${domain}/#/${pageUrl}?token=${token}&mp_redirect=${redirect}&inviteCode=${inviteCode}`
}

export const goWebview = ({
  domain = config.siteDomain,
  pageUrl,
  redirect,
  token,
  inviteCode
}) => {
  let encodedUrl = encodeURIComponent(getGoUrl({
    domain,
    pageUrl,
    redirect,
    token,
    inviteCode
  }));
  console.log(decodeURIComponent(encodedUrl), 'nnnnnnnnnnnnnnnnnnnn');
  wx.navigateTo({
    url: `/pages/webview/index?url=${encodedUrl}`,
  });
};

